function res = FPCApredict( model, feat )


%clear all; clc;
%load('recommendationData');

probe_vali = model.feat;
loss_vali = model.res;

probe_test = feat;
loss_test = zeros( size( probe_test, 1) , size( loss_vali, 2) );

if 0
    for i = 1:size(loss_vali,1)
        loss_vali(i,:) = loss_vali(i,:) - min(loss_vali(i,:));
    end
end

if 0
    for i = 1:size( probe_vali ,2 )
        m = mean( probe_vali(:,i) );
        probe_vali(:,i) = probe_vali(:,i) - m;
        probe_test(:,i) = probe_test(:,i) - m;
    end
end



n_test = size(loss_test, 1);
dim_loss = size( loss_test, 2);

dim_probe = size(probe_vali, 2);

sr = 0.25;%dim_loss / (dim_loss+dim_probe)/2;%sr = 0.25;

X = [ loss_test' loss_vali' ; probe_test' probe_vali'];




m = size(X,1);
n = size(X,2);
p = round(m*n*sr);

r = 4;

% fr is the freedom of set of rank-r matrix, maxr is the maximum rank one
% can recover with p samples, which is the max rank to keep fr < 1
fr = r*(m+n-r)/p; maxr = floor(((m+n)-sqrt((m+n)^2-4*p))/2);

A = ones(size( X ) );
A( 1:dim_loss , 1:n_test ) = 0;
A = A(:);
A = find( A~=0 );

xs = X;

opts = get_opts_FPCA(xs,maxr,m,n,sr,fr); 


%xs is rank r
b = reshape(xs,m*n,1); b = b(A);

Out = FPCA_MatComp(m,n,A,b,opts);

res = Out.x( 1:dim_loss, 1:n_test )';
